﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MashGen.Engine.Expressions
{
    public class Negative : AbstractExpression
    {
        public AbstractExpression Expression { get; private set; }

        public Negative(AbstractExpression expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }
            Expression = expression;
        }

        public override R Vist<R, P>(IExpressionVisitor<R, P> visitor, P parameter = default(P))
        {
            return visitor.VisitNegative(this, parameter);
        }

        public override bool Equals(AbstractExpression other)
        {
            var otherNegative = other as Negative;
            if (ReferenceEquals(otherNegative, null))
            {
                return false;
            }
            return Expression.Equals(otherNegative.Expression);
        }

        public override int GetHashCode()
        {
            return 3 * Expression.GetHashCode();
        }
    }
}
